package com.sail.www.client.component;

import com.google.gwt.user.client.ui.Widget;
import com.sail.www.client.ui.Page;

public abstract class Component {

	private int initCount;
	private Widget widget;
	private Page page;

	public Component(Widget widget, Page page) {
		this.widget = widget;
		this.page = page;
		init();
	}

	/**
	 * must call setInitStop method
	 */
	protected abstract void init();

	public abstract void go();

	protected void setInitStop(int value) {
		initCount = value;
	}

	protected void initStop() {
		if (initCount > 0) {
			initCount--;
		}
		if (initCount == 0) {
			page.show();
		}
	}

	public Widget getView() {
		return widget;
	}

}
